#include"progress.h"

//彩色进度条
void Progress1()
{
  int i = 0;
  char str[Num];
	memset(str,'\0',sizeof(str));
  printf("[%d%%]\033[41;32;31m%-103s\033[0m\r",0,str);
  fflush(stdout);
  for(i=0;i<Num;++i)
  {
    str[i] = ' ';
		printf("[%d%%]\033[42;32;31m%s\033[0m\r",i,str);
    usleep(100000);
  }
  printf("\n");
}

//仿Linux进度条
void Progress2()
{
  int i = 0;
  char str[Num];
	char s[]="/-\\";
	memset(str,'\0',sizeof(str));
  for(i=0;i<Num;++i)
  {
		printf("[\033[40;31m%-101s\033[0m][%d%%][%c]\r",str,i,s[i%4]);
    if(i < Num-1)
    {
      str[i+1]=Head;
    }
    
    if(i == 47)
    {
      str[i] = 'l';
    }
    else if(i == 48)
    {
      str[i] = 'o';
    }
    else if(i == 49)
    {
      str[i] = 'a';
    }
    else if(i == 50)
    {
      str[i] = 'd';
    }
    else if(i == 51)
    {
      str[i] = 'i';
    }
    else if(i == 52)
    {
      str[i] = 'n';
    }
    else if(i == 53)
    {
      str[i] = 'g';
    }
    else
    {
      str[i] = Body;
    }
    usleep(50000);
  }
  memset(str,'=',sizeof(str)-1);
  str[48]='o';
  str[49]='v';
  str[50]='e';
  str[51]='r';
  printf("[\033[40;32m%-100s\033[0m][%d%%][%c]\r",str,i-1,s[i%4]);
  printf("\n");
}